import cv2

import  numpy as np
img=cv2.imread('1.jpg')
kernel=cv2.getStructuringElement(cv2.MORPH_RECT,(5,5))
# erode=cv2.erode(img,kernel,iterations=1)
# dilate=cv2.dilate(erode,kernel,iterations=1)
img1 = cv2.morphologyEx(img, cv2.MORPH_OPEN, kernel,iterations=1)
cv2.imshow('img',img)
cv2.imshow('erode',img1)
# cv2.imshow('dilate',dilate)
cv2.waitKey(0)